home *** CD-ROM | disk | FTP | other *** search
- on AnimationSystemInitialize
- global ListAnim, ListRolls, ListSounds
- set ListRolls to []
- set ListAnim to []
- end
-
- on soundSystemInitialize
- global vol, ListSounds, BTNSOUNDCHANNEL
- set the soundLevel to 4
- set BTNSOUNDCHANNEL to 4
- set ListSounds to []
- set vol to 255
- end
-
- on NonThreadedAnimSeq spriteNum, ImageList, delay, Unpuppet
- set nbImages to count(ImageList)
- set i to 1
- puppetSprite(spriteNum, 1)
- repeat while i <= nbImages
- set the member of sprite spriteNum to member getAt(ImageList, i)
- updateStage()
- set i to i + 1
- wait(delay)
- end repeat
- puppetSprite(spriteNum, not Unpuppet)
- end
-
- on startAnim spriteNum, rootName, listFrames, delay, loop, Unpuppet
- global ListAnim
- append(ListAnim, [spriteNum, rootName, listFrames, delay, 0, the ticks, 0, loop, Unpuppet])
- end
-
- on stopAnim spriteNum
- global ListAnim
- set check to checkAnim(spriteNum)
- if check > 0 then
- if getAt(getAt(ListAnim, check), 9) = 1 then
- puppetSprite(spriteNum, 0)
- end if
- deleteAt(ListAnim, check)
- end if
- end
-
- on checkAnim spriteNum
- global ListAnim
- set i to 1
- set nbAnim to count(ListAnim)
- repeat while i <= nbAnim
- if spriteNum = getAt(getAt(ListAnim, i), 1) then
- return i
- end if
- set i to i + 1
- end repeat
- return 0
- end
-
- on mixDownAnim
- global ListAnim
- set i to 1
- repeat while i <= count(ListAnim)
- set spriteNum to getAt(getAt(ListAnim, i), 1)
- set listFrames to getAt(getAt(ListAnim, i), 3)
- set nbframes to count(listFrames)
- set delay to getAt(getAt(ListAnim, i), 4)
- set lastFrame to getAt(getAt(ListAnim, i), 5)
- set lastTick to getAt(getAt(ListAnim, i), 6)
- set nbTimes to getAt(getAt(ListAnim, i), 7)
- set loop to getAt(getAt(ListAnim, i), 8)
- set Unpuppet to getAt(getAt(ListAnim, i), 9)
- puppetSprite(spriteNum, 1)
- if ((the ticks - lastTick) >= delay) or (lastFrame = 0) then
- if loop = 0 then
- stopAnim(spriteNum)
- else
- if loop < 0 then
- if lastFrame = nbframes then
- set lastFrame to 1
- else
- set lastFrame to lastFrame + 1
- end if
- set the member of sprite spriteNum to member getAt(listFrames, lastFrame)
- updateStage()
- setAt(getAt(ListAnim, i), 5, lastFrame)
- setAt(getAt(ListAnim, i), 6, the ticks)
- setAt(getAt(ListAnim, i), 7, nbTimes)
- else
- if lastFrame = nbframes then
- set lastFrame to 1
- set nbTimes to nbTimes + 1
- else
- set lastFrame to lastFrame + 1
- end if
- if nbTimes = loop then
- stopAnim(spriteNum)
- else
- set the member of sprite spriteNum to member getAt(listFrames, lastFrame)
- updateStage()
- setAt(getAt(ListAnim, i), 5, lastFrame)
- setAt(getAt(ListAnim, i), 6, the ticks)
- setAt(getAt(ListAnim, i), 7, nbTimes)
- end if
- end if
- end if
- end if
- set i to i + 1
- end repeat
- end
-
- on forcePlaySound snd, chnl
- if soundBusy(chnl) then
- sound stop chnl
- end if
- puppetSound(chnl, snd)
- end
-
- on playsound snd, chnl, vol
- if not soundBusy(chnl) then
- if not voidp(vol) then
- set the volume of sound chnl to vol
- end if
- puppetSound(chnl, snd)
- updateStage()
- return 1
- end if
- return 0
- end
-
- on HardPlaySound snd, chnl
- if not soundBusy(chnl) then
- puppetSound(chnl, snd)
- updateStage()
- repeat while soundBusy(chnl)
- end repeat
- return 1
- end if
- return 0
- end
-
- on checkSound snd, chnl
- global ListSounds
- set i to 1
- set nbsound to count(ListSounds)
- repeat while i <= nbsound
- if (snd = getAt(getAt(ListSounds, i), 1)) and (chnl = getAt(getAt(ListSounds, i), 2)) then
- return i
- end if
- set i to i + 1
- end repeat
- return 0
- end
-
- on startSoundSequence snd, chnl, vol, delay, loop
- global ListSounds
- if checkSound(snd, chnl) = 0 then
- append(ListSounds, [snd, chnl, vol, delay, the ticks, 0, loop])
- end if
- end
-
- on stopSoundSequence snd, chnl
- global ListSounds
- set check to checkSound(snd, chnl)
- if check > 0 then
- deleteAt(ListSounds, check)
- end if
- end
-
- on mixDownSound
- global ListSounds
- set i to 1
- repeat while i <= count(ListSounds)
- set sound to getAt(getAt(ListSounds, i), 1)
- set channel to getAt(getAt(ListSounds, i), 2)
- set vol to getAt(getAt(ListSounds, i), 3)
- set delay to getAt(getAt(ListSounds, i), 4)
- set lastTick to getAt(getAt(ListSounds, i), 5)
- set nbTimesPlayed to getAt(getAt(ListSounds, i), 6)
- set maxTimesToPlay to getAt(getAt(ListSounds, i), 7)
- if nbTimesPlayed = maxTimesToPlay then
- stopSoundSequence(sound, channel)
- else
- if ((the ticks - lastTick) >= delay) or (nbTimesPlayed = 0) then
- forcePlaySound(sound, channel)
- set nbTimesPlayed to nbTimesPlayed + 1
- setAt(getAt(ListSounds, i), 5, the ticks)
- setAt(getAt(ListSounds, i), 6, nbTimesPlayed)
- end if
- end if
- set i to i + 1
- end repeat
- end
-
- on checkRoll spriteNum
- global ListRolls
- set i to 1
- set nbRolls to count(ListRolls)
- repeat while i <= nbRolls
- set trigger to getAt(getAt(getAt(ListRolls, i), 1), 1)
- if spriteNum = getAt(trigger, 1) then
- return i
- end if
- set i to i + 1
- end repeat
- return 0
- end
-
- on rollOverBtn rolls, snd, chnl, vol, sndDelay, loop
- global ListRolls
- set trigger to getAt(rolls, 1)
- set triggerSprNum to getAt(trigger, 1)
- if checkRoll(triggerSprNum) = 0 then
- if not voidp(snd) then
- startSoundSequence(snd, chnl, vol, sndDelay, loop)
- end if
- append(ListRolls, [rolls, snd, chnl])
- set i to 1
- repeat while i <= count(rolls)
- set spriteNum to getAt(getAt(rolls, i), 1)
- set rootName to getAt(getAt(rolls, i), 2)
- set listFrames to getAt(getAt(rolls, i), 3)
- set delay to getAt(getAt(rolls, i), 4)
- startAnim(spriteNum, rootName, listFrames, delay, -1, 1)
- set i to i + 1
- end repeat
- end if
- end
-
- on cleanUpRolls
- global ListRolls
- set i to 1
- set nbRolls to count(ListRolls)
- repeat while i <= nbRolls
- set ro to getAt(ListRolls, i)
- set roAnim to getAt(ro, 1)
- set snd to getAt(ro, 2)
- set chnl to getAt(ro, 3)
- set roTrigger to getAt(getAt(ro, 1), 1)
- set spriteNum to getAt(roTrigger, 1)
- if not rollOver(spriteNum) then
- stopSoundSequence(snd, chnl)
- set j to 1
- set nbAnimSpr to count(roAnim)
- repeat while j <= nbAnimSpr
- set spriteNum to getAt(getAt(roAnim, j), 1)
- stopAnim(spriteNum)
- set j to j + 1
- end repeat
- deleteAt(ListRolls, i)
- set nbRolls to nbRolls - 1
- end if
- set i to i + 1
- end repeat
- end
-